
import sys
import time
import os

script_dir = os.path.dirname(__file__)
pymongo_dir = os.path.join(script_dir, "mongo-python-driver-3.7.2")
# sys.path.append(pymongo_dir)

sys.path.append(
    "/home/long/work/sample/python/mongodb/mongo-python-driver-3.7.2")

import pymongo
import bson


client = pymongo.MongoClient("172.17.0.2", 27017)
db = client.test
col = db.xx
start_t = time.time()
insert_count = 10000

# print dir(bson)
# for i in xrange(insert_count):
#     with open("/dev/random") as f:
#         data = f.read(10 * 1024)  # 10k
#     col.insert({"time": time.time(), "fff": bson.binary.Binary(data)})
end_t = time.time()

print "count: ", col.count()

print "insert [%d] use time %f" % (insert_count, end_t - start_t)
for c in col.find():
    # print c
    print type(c)
    break
client.close()

# col.remove()
